package net.phoenix.repository.query.qom2;

import javax.jcr.query.qom.ChildNodeJoinCondition;

/**
 * <code>ChildNodeJoinConditionImpl</code>...
 */
public class ChildNodeJoinConditionImpl extends JoinConditionImpl implements ChildNodeJoinCondition {

	/**
	 * The name of the child selector.
	 */
	private final String childSelectorName;

	/**
	 * The name of the parent selector.
	 */
	private final String parentSelectorName;

	ChildNodeJoinConditionImpl(NamePathResolver resolver, String childSelectorName, String parentSelectorName) {
		super(resolver);
		this.childSelectorName = childSelectorName;
		this.parentSelectorName = parentSelectorName;
	}

	/**
	 * Gets the name of the child selector.
	 * 
	 * @return the selector name; non-null
	 */
	public String getChildSelectorName() {
		return (childSelectorName);
	}

	/**
	 * Gets the name of the parent selector.
	 * 
	 * @return the selector name; non-null
	 */
	public String getParentSelectorName() {
		return (parentSelectorName);
	}

	// ------------------------< AbstractQOMNode >-------------------------------

	/**
	 * Accepts a <code>visitor</code> and calls the appropriate visit method
	 * depending on the type of this QOM node.
	 * 
	 * @param visitor
	 *            the visitor.
	 */
	public Object accept(QOMTreeVisitor visitor, Object data) throws Exception {
		return visitor.visit(this, data);
	}

	// ------------------------< Object
	// >----------------------------------------

	public String toString() {
		String child = getChildSelectorName();
		String parent = getParentSelectorName();
		return "ISCHILDNODE(" + child + ", " + parent + ")";
	}

}
